package org.jetlinks.pro.clickhouse.engine;

import lombok.Generated;
import org.hswebframework.ezorm.core.FeatureId;
import org.hswebframework.ezorm.core.FeatureType;
import org.hswebframework.ezorm.core.meta.Feature;

/**
 * ClickHouse 表引擎定义
 *
 * @author zhouhao
 * @see MergeTree
 * @see ReplicatedMergeTree
 * @see Distributed
 * @since 1.10
 */
public interface Engine extends Feature {

    String ID_VALUE = "CH_Engine";

    FeatureId<Engine> ID = FeatureId.of(ID_VALUE);

    /**
     * 构建创建表的SQL语句
     *
     * @param table      表名
     * @param columnDefs 列定义
     * @return SQL语句
     */
    String buildCreateTableSql(String table, String... columnDefs);

    /**
     * @return 是否为分布式表
     */
    boolean isDistributed();

    /**
     * @return 分布式表集群名称
     */
    String getCluster();

    /**
     * 复制一个新的引擎
     *
     * @return 新的引擎
     */
    Engine copy();


    @Override
    @Generated
    default String getId() {
        return ID_VALUE;
    }

    @Override
    @Generated
    default String getName() {
        return getClass().getSimpleName();
    }

    @Override
    @Generated
    default FeatureType getType() {
        return ClickHouseFeatureType.Engine;
    }
}